package com.zhangtai.Neusoft.controller;

//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.zhangtai.Neusoft.dto.PerformanceDto;
//import com.zhangtai.Neusoft.dto.SalaryDto;
//import com.zhangtai.Neusoft.service.NeuEmployeeBaseInfoService;
//import com.zhangtai.Neusoft.service.NeuEmployeeSalaryService;
//import com.zhangtai.Neusoft.vo.SalaryGroupVo;
//import com.zhangtai.common.annotation.SysAuthorityLog;
//import com.zhangtai.modules.controller.admin.JobController;
//import com.zhangtai.modules.controller.aouthLogin.LoginController;
//import com.zhangtai.modules.controller.aouthLogin.MemberLoginController;
//import com.zhangtai.modules.dao.EmployeeEducationDao;
//import com.zhangtai.modules.dao.EmployeeInfoDao;
//import com.zhangtai.modules.dao.ssqlDao.EmployeeBaseDao;
//import com.zhangtai.modules.dao.ssqlDao.JobDaoMssql;
//import com.zhangtai.modules.entity.employee.EmployeeInfoEntity;
//import com.zhangtai.modules.service.baseFromMssql.BaseMssqlServiceImpl;
//import com.zhangtai.utils.R;
//import com.zhangtai.utils.StringUtils;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.CollectionUtils;
//import org.springframework.util.ObjectUtils;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.validation.constraints.NotNull;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Map;
//
//@RestController
//@Slf4j
//@Api(tags="与东软对接接口信息")
//@RequestMapping("/neusoft")
//public class NeusoftEmployeeController {
//    @Autowired
//    private JobDaoMssql jobDaoMssql;
//
//    @Autowired
//    private NeuEmployeeSalaryService neuEmployeeSalaryService;
//    @Autowired
//    private MemberLoginController memberLoginController;
//    @Autowired
//    private EmployeeBaseDao employeeBaseDao;
//    @Autowired
//    private NeuEmployeeBaseInfoService neuEmployeeBaseInfoService;
//    @Autowired
//    private JobController jobController;
//    @Autowired
//    private BaseMssqlServiceImpl baseMssqlService;
//    @Autowired
//    private BaseMssqlServiceImpl baseMssqlServiceImpl;
//    @Autowired
//    private EmployeeInfoDao employeeInfoDao;
//    @Autowired
//    private EmployeeEducationDao employeeEducationDao;
//    @Autowired
//    private LoginController loginController;
//
//    @GetMapping("/getEmployeeSalary")
//    @ApiOperation("个人工资")
//    public R getEmployeeSalary(HttpServletRequest request,@RequestParam(value = "code") String code,@RequestParam(value = "yymm") String yymm,@RequestParam(value = "endyymm") String endyymm) throws Exception {
//        return neuEmployeeSalaryService.getEmployeeWage(code,yymm,endyymm);
//    }
//
//    @GetMapping("/getEmployeeSalaryModule")
//    @ApiOperation("个人工资模块信息")
//    public R getEmployeeSalaryModule(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
//        //String bbeginDate= DateUtils.formatYM(new Date())+"-01";
//        List<SalaryDto> salaryDtoList= employeeBaseDao.getEmployeeSalaryList(code,null);
//        return R.ok(salaryDtoList);
//    }
//
//    @PostMapping("/getEmployeeSalaryModuleByCode")
//    @ApiOperation("个人工资模块信息")
//    public R getEmployeeSalaryModuleByCode(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
//        JSONObject data =loginController.getUserInfo(request).getData();
//        if (ObjectUtils.isEmpty(data)) {
//            return  R.error("请先登录");
//        }
//        List<SalaryDto> salaryDtoList= employeeBaseDao.getEmployeeSalaryList(code,null);
//        SalaryDto salaryDto=new SalaryDto();
//        if(!CollectionUtils.isEmpty(salaryDtoList)){
//            salaryDto=salaryDtoList.get(0);
//        }
//        return R.ok(salaryDto);
//    }
//
//
//    @GetMapping("/saveAndUpdateEmployeeInfoOne")
//    @ApiOperation("同步员工基础信息到共享中心")
//    @SysAuthorityLog("同步员工基础信息到共享中心")
//    public R saveAndUpdateEmployeeInfoOne(@RequestParam(value = "code") String code, HttpServletRequest request) throws Exception {
//        neuEmployeeBaseInfoService.saveEmployeeInfoSchedule(code);
//        return R.ok();
//    }
//
//    @GetMapping("/saveAndUpdateEmployeeInfoList")
//    @ApiOperation("同步员工基础信息到共享中心根据codeStr")
//    @SysAuthorityLog("同步员工基础信息到共享中心根据codeStr")
//    public R saveAndUpdateEmployeeInfoList(@RequestParam(value = "codeStr") String codeStr, HttpServletRequest request) throws Exception {
//        String[] codes=codeStr.split(",");
//        for (String code:codes){
//            neuEmployeeBaseInfoService.saveEmployeeInfoSchedule(code);
//        }
//        return R.ok();
//    }
//
//
//    @GetMapping("/getPerformanceList")
//    @ApiOperation("个人绩效信息")
//    public R getPerformanceList(@RequestParam(value = "code") String code,
//                                @RequestParam(value = "assessMonthStart") String assessMonthStart,
//                                @RequestParam(value = "assessMonthEnd") String assessMonthEnd,HttpServletRequest request) throws Exception {
//        List<PerformanceDto>  performanceList = employeeBaseDao.getPerformanceList(code,assessMonthStart,assessMonthEnd);
//        return R.ok(performanceList);
//    }
//    @GetMapping("/findDictionary")
//    @ApiOperation("根据typeCode获取配置信息")
//    public R getPerformanceList(@NotNull(message = "typeCode不能为空") @RequestParam(value = "typeCode",required = true) String typeCode, HttpServletRequest request) throws Exception {
//        Map<String,String> map=neuEmployeeBaseInfoService.findDictionary(typeCode);
//        JSONArray jsonArray=new JSONArray();
//        for(String key:map.keySet()){
//            JSONObject jsonObject=new JSONObject();
//            jsonObject.put("label",map.get(key));
//            jsonObject.put("value",key);
//            jsonArray.add(jsonObject);
//        }
//        return R.ok(jsonArray);
//    }
//
//
//
//
//    @GetMapping("/saveEmployeeByOrgId")
//    @ApiOperation("根据公司查找员工code 并同步ehr员工信息到共享中心")
//    public R saveEmployeeByOrgId(@RequestParam(value = "orgId") Long orgId,HttpServletRequest request) throws Exception {
//        List<Long> orgIds = new ArrayList<Long>();//获取用户对应组织
//        List<String> codes=new ArrayList<>();
//       if(!ObjectUtils.isEmpty(jobController.orgAllChildrenMap.get(orgId))) {
//           orgIds.addAll(jobController.orgAllChildrenMap.get(orgId));
//       }
//       if(!CollectionUtils.isEmpty(orgIds)){
//          codes =  employeeBaseDao.getEmployeeCode(orgIds);
//       }
//       if(!CollectionUtils.isEmpty(codes)){
//            for (String code:codes){
//                neuEmployeeBaseInfoService.saveEmployeeInfoSchedule(code);
//            }
//       }
//        return R.ok();
//    }
//
//    @GetMapping("/saveEmployeeInfoSchedule")
//    @ApiOperation("同步现有员工附表信息 并同步ehr员工信息到共享中心")
//    public R saveEmployeeInfoSchedule(HttpServletRequest request) throws Exception {
//
//        List<EmployeeInfoEntity> employeeInfoEntityList= employeeInfoDao.selectList(new QueryWrapper<EmployeeInfoEntity>().eq("is_delete",0));
//        if(!CollectionUtils.isEmpty(employeeInfoEntityList)){
//            for (EmployeeInfoEntity entity:employeeInfoEntityList){
//                if(!StringUtils.isEmpty(entity.getCode())){
//                  neuEmployeeBaseInfoService.saveAndUpdateEmployeeInfoOne(entity.getCode(),entity.getOid()+"");
//                }
//            }
//        }
//        return R.ok();
//    }
//
//    @GetMapping("/saveInternalAward")
//    @ApiOperation("同步现有员工奖惩信息 并同步ehr员工奖惩信息到共享中心")
//    public R saveInternalAward(HttpServletRequest request) throws Exception {
//
//        List<EmployeeInfoEntity> employeeInfoEntityList= employeeInfoDao.selectList(new QueryWrapper<EmployeeInfoEntity>().eq("is_delete",0));
//        if(!CollectionUtils.isEmpty(employeeInfoEntityList)){
//            for (EmployeeInfoEntity entity:employeeInfoEntityList){
//                if(!StringUtils.isEmpty(entity.getCode())){
//                    neuEmployeeBaseInfoService.saveInternalAward(entity.getCode(),entity.getOid()+"");
//                }
//            }
//        }
//        return R.ok();
//    }
//
//    @GetMapping("/saveEmployeeInfoList")
//    @ApiOperation("同步员工基础信息到共享中心")
//    public R saveEmployeeInfoList(HttpServletRequest request,String code) throws Exception {
//
//        if(!StringUtils.isEmpty(code)){
//            List<EmployeeInfoEntity> employeeInfoEntityList= employeeInfoDao.selectList(new QueryWrapper<EmployeeInfoEntity>().eq("code",code));
//            if(!CollectionUtils.isEmpty(employeeInfoEntityList)){
//                for (EmployeeInfoEntity entity:employeeInfoEntityList){
//                        neuEmployeeBaseInfoService.saveEmployeeInfoList(entity.getCode());
//                }
//            }
//            return R.ok();
//        }
//        List<EmployeeInfoEntity> employeeInfoEntityList= employeeInfoDao.selectList(new QueryWrapper<EmployeeInfoEntity>().eq("is_delete",0));
//        if(!CollectionUtils.isEmpty(employeeInfoEntityList)){
//            for (EmployeeInfoEntity entity:employeeInfoEntityList){
//                if(!StringUtils.isEmpty(entity.getCode())){
//                    neuEmployeeBaseInfoService.saveEmployeeInfoList(entity.getCode());
//                }
//            }
//        }
//        return R.ok();
//    }
//
//    @GetMapping("/getSalaryGroupList")
//    @ApiOperation("获取员工现在的薪资组")
//    public R getSalaryGroupList(HttpServletRequest request,String code) throws Exception {
//        JSONObject data =loginController.getUserInfo(request).getData();
//        if (ObjectUtils.isEmpty(data)) {
//            return  R.error("请先登录");
//        }
//        if(!StringUtils.isEmpty(code)){
//            List<SalaryGroupVo>  salaryGroupVoList  = employeeBaseDao.getSalaryGroupList(code);
//            if(!CollectionUtils.isEmpty(salaryGroupVoList)){
//                return R.ok(salaryGroupVoList.get(0));
//             }
//        }
//    return R.ok();
//    }
//
//
//    @GetMapping("/test")
//    @ApiOperation("测试")
//    public R test( HttpServletRequest request) throws Exception {
//        neuEmployeeBaseInfoService.getComputerSubsidy();
//        return R.ok();
//    }


//}
